//
//  CellofContent.m
//  HYHOME
//
//  Created by Mac on 16/1/22.
//  Copyright © 2016年 Mac. All rights reserved.
//

#import "CellofContent.h"
#import "Modelcontent.h"
#import "UIImageView+WebCache.h"


@implementation CellofContent
- (void)dealloc{

    
    [_labelOflikes_count release];
    [_labelOftitle release];
    [_imgV release];
    [super dealloc];




}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{


    self =  [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        
        [self createSubView];
        
    }

    return self;
}

- (void)createSubView{
    
    self.imgV = [[UIImageView alloc]init];
    [self.contentView addSubview:self.imgV];
    
    
    self.labelOftitle = [[UILabel alloc]init];
    [self.contentView addSubview:self.labelOftitle];
    self.labelOftitle.numberOfLines = 0;

    self.labelOflikes_count =[[ UILabel alloc]init];
    [self.contentView addSubview:self.labelOflikes_count];
    
    self.pic = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"iconfont-xihuan"]];
    [self.labelOflikes_count addSubview:self.pic];
    
    
    
    [self.labelOflikes_count release];
    [self.imgV release];
    [self.labelOftitle release];


}
- (void)passTwoModel:(Modelcontent *)model{
    [self.imgV sd_setImageWithURL:[NSURL URLWithString:model.cover_image_url] placeholderImage:[UIImage imageNamed:@"jz"]];
    
    self.labelOftitle.text = model.title;
    
    self.labelOflikes_count.text = [NSString stringWithFormat:@"       %@",[model.likes_count stringValue] ];
    
    

    
    

}

- (void)layoutSubviews{

    [super layoutSubviews];
    self.imgV.frame = CGRectMake(10, 10,self.frame.size.width - 20 , self.frame.size.height- 10);
    self.imgV.layer.shadowOffset = CGSizeMake(0, 1);
    self.imgV.layer.shadowOpacity = 1;
    
    self.imgV.layer.cornerRadius = 10;
    self.imgV.layer.masksToBounds = YES;

    self.labelOftitle.frame = CGRectMake(10, self.frame.size.height - 36, self.frame.size.width - 20, 25);
    
    self.labelOftitle.textColor = [UIColor whiteColor];
    self.labelOftitle.textAlignment = NSTextAlignmentCenter;
    
    
    self.likeback.frame= CGRectMake(self.frame.size.width- 110,30, 90, 30);
    self.likeback.backgroundColor = [UIColor blackColor];
    self.likeback.alpha = 1;
    self.likeback.layer.cornerRadius = 15;
    self.likeback.layer.masksToBounds = YES;

    self.labelOflikes_count.frame= CGRectMake(self.frame.size.width / 4 * 3 - 20, 30, self.imgV.frame.size.width / 4, 30);
    self.labelOflikes_count.textColor = [UIColor whiteColor];
    self.labelOflikes_count.backgroundColor = [UIColor blackColor];
    self.labelOflikes_count.alpha = 0.6;
    self.labelOflikes_count.layer.cornerRadius = 12;
    self.labelOflikes_count.layer.masksToBounds = YES;

  
    self.pic.frame = CGRectMake(7, 4, self.labelOflikes_count.frame.size.height - 10, self.labelOflikes_count.frame.size.height - 10);
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
